<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 定义一个JSON对象，属性名必须使用双引号引起来，不能使用单引号
        var p={
            "name":"张三",
            "age":24,
            "address":"USA",
            "height":189,
            "isMarried":false,
            "friends":"no",
            "show":function(){//在JSON对象中一般不定义方法
                console.log("我的名字："+this.name);
            }
        };
        console.log(p);
        console.log(p.name);
        console.log(p["age"]);
        p.show();

        //复合属性，即对象的属性值为对象
        var user={
            "name":{
                "firstName":"杨",
                "lastName":"昌盛"
            },
            "age":20
        };
        console.log("免贵姓："+user.name.firstName);
        console.log("免贵姓："+user["name"]["firstName"]);
        console.log("免贵姓："+user.name["firstName"]);

    </script>
</head>
<body>
    
</body>
</html>